{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "加菜:羊肉串\n",
      "没点那么多菜\n",
      "加菜:牛肉串\n",
      "没点那么多菜\n",
      "下单啦:\n",
      "傅俊,你的菜单是:\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from abc import abstractmethod,ABCMeta\n",
    "class cooker(object):\n",
    "    #厨师\n",
    "    def __init__(self):\n",
    "        self._num_yang=1\n",
    "        self._num_niu=1\n",
    "    def cook_yang(self):\n",
    "        if self._num_yang<=3:\n",
    "            print('烧烤羊肉窜')\n",
    "            self._num_yang+=1\n",
    "        else:\n",
    "            print('没有羊肉了')\n",
    "    def cook_niu(self):\n",
    "        if self._num_niu<=3:\n",
    "            print('烧烤牛肉串')\n",
    "            self._num_niu+=1\n",
    "        else:\n",
    "            print('没有牛肉串了')\n",
    "\n",
    "class command(object):\n",
    "    #抽象菜单\n",
    "    __metaclass__=ABCMeta\n",
    "    \n",
    "    def __init__(self,name):\n",
    "        self.cooker=cooker()\n",
    "        self.name=name\n",
    "    @abstractmethod\n",
    "    def cook(self):\n",
    "        pass\n",
    "class commandyang(command):\n",
    "    def __init__(self,name):\n",
    "        super(commandyang,self).__init__(name)\n",
    "    def cook(self):\n",
    "        self.cooker.cook_yang()\n",
    "class commandniu(command):\n",
    "    def __init__(self,name):\n",
    "        super(commandniu,self).__init__(name)\n",
    "    def cook(self):\n",
    "        self.cooker.cook_niu()\n",
    "class waiter(object):\n",
    "    def __init__(self):\n",
    "        self._command_list=[]\n",
    "        self._menu=None\n",
    "        self._kehu=None\n",
    "    def set_kehu(self,kehu):\n",
    "        self._kehu=kehu\n",
    "    def set_order(self,command,num=1):\n",
    "        print('加菜:'+command.name)\n",
    "        try:\n",
    "            for i in range(num):\n",
    "                self._command_list.remove(command)\n",
    "        except Exception as e:\n",
    "            print('没点那么多菜')\n",
    "    def notify(self):\n",
    "        print('下单啦:')\n",
    "        self._menu=order(self._kehu,self._command_list)\n",
    "        self._menu.show()\n",
    "        for command in self._command_list:\n",
    "            command.cook()\n",
    "        self._command_list=[]\n",
    "        print(\"\")\n",
    "        \n",
    "class order(object):\n",
    "    def __init__(self,name,command_list):\n",
    "        self._command_list=command_list\n",
    "        self._name=name\n",
    "    def set_order(self,command_list):\n",
    "        self._command_list=command_list\n",
    "    def set_name(self,name):\n",
    "        self._name=name\n",
    "        \n",
    "    def show(self):\n",
    "        print(self._name+\",你的菜单是:\")\n",
    "        for command in self._command_list:\n",
    "            print(command.name)\n",
    "        print('')\n",
    "if __name__=='__main__':\n",
    "    command_yang=commandyang('羊肉串')\n",
    "    command_niu=commandniu('牛肉串')\n",
    "    waiter=waiter()\n",
    "    \n",
    "    #营业\n",
    "    waiter.set_kehu('傅俊')\n",
    "    waiter.set_order(command_yang,4)\n",
    "    waiter.set_order(command_niu,5)\n",
    "    waiter.notify()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__self_class__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__thisclass__']\n"
     ]
    }
   ],
   "source": [
    "class p:\n",
    "    def __init__(self):\n",
    "        pass\n",
    "class b(p):\n",
    "    def __init__(self):\n",
    "        print(dir(super()))\n",
    "b=b()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
